<include file="Public/header" />
<title>添加订单</title>
</head>
<body>
<div class="pd-20">
<form name="form" id="form" method="post">
	<table class="table table-border table-bordered table-bg">

		<tbody>
			<tr class="text-c">
					<td width="15%" class="text-r" style="background-color:#f5f5f5">订单编号：</td>
					<td class="text-l">
						<input type="hidden" class="input-text" value="OD<{:date('ymd',time())}><{$serial_number}>" placeholder="订单编号" id="order_no" name="order_no">
						<input type="text" class="input-text" value="OD<{:date('ymd',time())}><{$serial_number}>" placeholder="订单编号"  disabled="disabled">
					</td>
					<td width="15%" class="text-r" style="background-color:#f5f5f5">申请部门：</td>
					<td class="text-l" style="width:35%;">
						<select  class="input-text" id="section_no" name="section_no">
							<option value="0">请选择</option>
							<volist name="section_list" id="vo">
								<option value="<{$vo.no}>" <if condition="$vo['no'] eq $detail['section_no']">selected</if>><{$vo.name}></option>
							</volist>
						</select>
					</td>						
			</tr>
			<tr class="text-c">
					<td width="15%" class="text-r" style="background-color:#f5f5f5">制单人：</td>
					<td class="text-l">
						<select  class="input-text people_make_no" id="people_make_no" name="people_make_no">
							<option value="0">请选择</option>
							<volist name="personnel_list" id="vo">
								<option value="<{$vo.no}>" <if condition="$vo['no'] eq $detail['people_make_no']">selected</if>><{$vo.name}></option>
							</volist>
						</select>
						
					</td>
					<td width="15%" class="text-r" style="background-color:#f5f5f5">业务员：</td>
					<td class="text-l">
						<select  class="input-text people_purchasing_no" id="people_purchasing_no" name="people_purchasing_no">
							<option value="0">请选择</option>
							<volist name="personnel_list" id="vo">
								<option value="<{$vo.no}>" <if condition="$vo['no'] eq $detail['people_purchasing_no']">selected</if>><{$vo.name}></option>
							</volist>
						</select>
					</td>						
			</tr>
			<tr class="text-c">
					<td width="15%" class="text-r" style="background-color:#f5f5f5">往来单位：</td>
					<td class="text-l">
						<select  class="input-text contacts_company_no" id="contacts_company_no" name="contacts_company_no">
							<option value="0">请选择</option>
							<volist name="company_list" id="vo">
								<option value="<{$vo.no}>" <if condition="$vo['no'] eq $detail['contacts_company_no']">selected</if>><{$vo.name}></option>
							</volist>
						</select>
					</td>
					<td width="15%" class="text-r" style="background-color:#f5f5f5">运输方式：</td>
					<td class="text-l">
						<select  class="input-text transport_cate" id="transport_cate" name="transport_cate">
							<option value="0">请选择</option>
							<option value="1">自提</option>
							<option value="2">第三方物流</option>
							<option value="3">送货</option>
						</select>
						<input type="text" name="logistics_no" style="display:none" class="input-text" value="" placeholder="运单号">
					</td>						
			</tr>
			<tr class="text-c uhide">
					<td width="15%" class="text-r" style="background-color:#f5f5f5">客户姓名：</td>
					<td class="text-l">
						<input type="text" class="input-text user_name" value="" placeholder="客户姓名" name="user_name">
					</td>
					<td width="15%" class="text-r" style="background-color:#f5f5f5">省：</td>
					<td class="text-l" style="width:35%;">
						<input type="text" class="input-text" value="" placeholder="省" name="province">
					</td>						
			</tr>
			<tr class="text-c uhide">
					<td width="15%" class="text-r" style="background-color:#f5f5f5">市：</td>
					<td class="text-l">
						<input type="text" class="input-text user_name" value="" placeholder="市" name="city">
					</td>
					<td width="15%" class="text-r" style="background-color:#f5f5f5">区/县：</td>
					<td class="text-l" style="width:35%;">
						<input type="text" class="input-text" value="" placeholder="区/县" name="area">
					</td>						
			</tr>
			<tr class="text-c uhide">
					<td width="15%" class="text-r" style="background-color:#f5f5f5">客户详细地址：</td>
					<td class="text-l" style="width:35%;">
						<input type="text" class="input-text" value="" placeholder="客户详细地址" name="user_address">
					</td>
					<td width="15%" class="text-r" style="background-color:#f5f5f5">身份证：</td>
					<td class="text-l" style="width:35%;">
						<input type="text" class="input-text" value="" placeholder="身份证" name="user_idcard">
					</td>				
			</tr>
			<tr class="text-c uhide">
					<td width="15%" class="text-r" style="background-color:#f5f5f5">联系电话：</td>
					<td class="text-l">
						<input type="text" class="input-text" value="" placeholder="联系电话" name="user_phone">
					</td>
					<td width="15%" class="text-r" style="background-color:#f5f5f5"></td>
					<td class="text-l">
					</td>					
			</tr>
		</tbody>
	</table>
</form>
		<div class="row cl">
			<div class="col-9 col-offset-3">
				<input class="btn btn-primary radius" type="submit" id="add" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
</div>
<script type="text/javascript">
	$('#contacts_company_no').change(function(){
			if($(this).val()!=0){
				$(".uhide").hide();
			}else{
				$(".uhide").show();
			}
	})
    $(function(){
		$(".transport_cate").change(function(){
			if($(this).val()==2){
				$('input[name=logistics_no]').show();
			}else{
				$('input[name=logistics_no]').hide();
			}
		});
		/*添加*/
        $("#add").click(function(){
			var section_no=$('#section_no').val();
			var order_no=$('#order_no').val();
			var people_make_no=$('.people_make_no').val();
			var people_purchasing_no=$('.people_purchasing_no').val();
			var contacts_company_no=$('.contacts_company_no').val();
			
			var user_name=$('input[name=user_name]').val();
			var province=$('input[name=province]').val();
			var city=$('input[name=city]').val();
			var area=$('input[name=area]').val();
			var user_address=$('input[name=user_address]').val();
			var user_idcard=$('input[name=user_idcard]').val();
			var user_phone=$('input[name=user_phone]').val();
			
            //询问
			if(order_no==""){
				layer.alert("订单编号不能为空");
				return false;
			}
			if(section_no=="0"){
				layer.alert("申请部门不能为空");
				return false;
			}
			if(people_make_no=="0"){
				layer.alert("请选择制单人");
				return false;
			}
			if(people_purchasing_no=="0"){
				layer.alert("请选择采购申请人");
				return false;
			}
			if(contacts_company_no=='0'){
				if(user_name==""){
					layer.alert("客户姓名不能为空");
					return false;
				}
				if(province==""){
					layer.alert("省不能为空");
					return false;
				}
				if(city==""){
					layer.alert("市不能为空");
					return false;
				}
				if(area==""){
					layer.alert("区/县不能为空");
					return false;
				}
				if(user_address==""){
					layer.alert("客户详细地址不能为空");
					return false;
				}
				<!-- if(user_idcard==""){ -->
					<!-- layer.alert("身份证不能为空"); -->
					<!-- return false; -->
				<!-- } -->
				if(user_phone==""){
					layer.alert("联系电话不能为空");
					return false;
				}
			}
			layer.confirm('是否确定添加此信息', {
			  btn: ['是','否'] 
			}, function(){
				$.ajax({
					type: 'POST',
					data: $("#form").serialize(),
					url: "<{:U('add')}>",
					success:function(data){
						if(data.status){
							layer.alert(data.info,function(){
									parent.window.location.href =parent.window.location.href;
							});
						}else{
							layer.msg(data.info);
						}
					}
				})
			});
        });

    })
</script>

</body>
</html>